1 <?php
2     include(
"../includes/config.php");
3     include(
"../includes/validate_data.php");
4     session_start();
5     
if(isset($_SESSION['manufacturer_login'])) {
6         
if($_SESSION['manufacturer_login'] == true) {
7             $id = $_GET[
'id'];
8             $query_selectUnitDetails =
"SELECT * FROM unit WHERE id='$id'";
9             $result_selectUnitDetails = mysqli_query($con,$query_selectUnitDetails);
10             $row_selectUnitDetails = mysqli_fetch_array($result_selectUnitDetails);
11             $unitName = $unitDetails =
"";
12             $unitNameErr = $requireErr = $confirmMessage =
"";
13             $unitNameHolder = $unitDetailsHolder =
"";
14             
if($_SERVER['REQUEST_METHOD'] == "POST") {
15                 
if(!empty($_POST['txtUnitName'])) {
16                     $unitNameHolder = $_POST[
'txtUnitName'];
17                     $result = validate_name($_POST[
'txtUnitName']);
18                     
if($result == 1) {
19                         $unitName = $_POST[
'txtUnitName'];
20                     }
21                     
else{
22                         $unitNameErr = $result;
23                     }
24                 }
25                 
if(!empty($_POST['txtunitDetails'])) {
26                     $unitDetails = $_POST[
'txtunitDetails'];
27                     $unitDetailsHolder = $_POST[
'txtunitDetails'];
28                 }
29                 
if($unitName != null) {
30                     $query_UpdateUnit =
"UPDATE unit SET unit_name='$unitName',unit_details='$unitDetails' WHERE id='$id'";
31                     
if(mysqli_query($con,$query_UpdateUnit)) {
32                         echo
"<script> alert(\"Unit Updated Successfully\"); </script>";
33                         header(
'Refresh:0;url=view_unit.php');
34                     }
35                     
else {
36                         $requireErr =
"Updating Unit Failed";
37                     }
38                 }
39                 
else {
40                     $requireErr =
"* Valid Unit Name is required";
41                 }
42             }
43         }
44         
else {
45             header(
'Location:../index.php');
46         }
47     }
48     
else {
49         header(
'Location:../index.php');
50     }
51 ?>
52 <!DOCTYPE html>
53 <html>
54 <head>
55     <title> Update Unit </title>
56     <link rel=
"stylesheet" href="../includes/main_style.css" >
57 </head>
58 <body>
59     <?php
60         include(
"../includes/header.inc.php");
61         include(
"../includes/nav_manufacturer.inc.php");
62         include(
"../includes/aside_manufacturer.inc.php");
63     ?>
64     <section>
65         <h1>Update Unit</h1>
66         <form action=
"" method="POST" class="form">
67         <ul
class="form-list">
68         <li>
69             <div
class="label-block"> <label for="unitName">Unit Name</label> </div>
70             <div
class="input-box"> <input type="text" id="unitName" name="txtUnitName" placeholder="Unit Name" value="<?php echo $row_selectUnitDetails['unit_name']; ?>" required /> </div> <span class="error_message"><?php echo $unitNameErr; ?></span>
71         </li>
72         <li>
73             <div
class="label-block"> <label for="unitDetails">Details</label> </div>
74             <div
class="input-box"><textarea id="unitDetails" name="txtunitDetails" placeholder="Details"><?php echo $row_selectUnitDetails['unit_details']; ?></textarea> </div>
75         </li>
76         <li>
77             <input type=
"submit" value="Update Unit" class="submit_button" /> <span class="error_message"> <?php echo $requireErr; ?> </span><span class="confirm_message"> <?php echo $confirmMessage; ?> </span>
78         </li>
79         </ul>
80         </form>
81     </section>
82     <?php
83         include(
"../includes/footer.inc.php");
84     ?>
85 </body>
86 </html>


Gõ tìm kiếm nhanh...